﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class JobSearchBySkills : System.Web.UI.Page
{
    string mode = "BySkills";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillSkills();
        }
    }

    protected void btnSeachBySkills_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtKeySkills.Text != "")
            {
                mode = clsEncryptionDecryption.EncryptQueryString(mode);
                Response.Redirect("JobSearchResult.aspx?mode=" + mode + "&skillset=" + clsEncryptionDecryption.EncryptQueryString(txtKeySkills.Text.Trim().ToLower()) + "&roleid=" + Convert.ToString(Request.QueryString["roleid"]));
            }
        }
        catch (Exception)
        {
            throw;
        }
    }

    protected void FillSkills()
    {
        try
        {
            clsSkillsMasterDAL objclsSkillsMasterDAL = new clsSkillsMasterDAL();
            List<IN_TB_SKILL_MST> objIN_TB_SKILL_MST = new List<IN_TB_SKILL_MST>();
            objIN_TB_SKILL_MST = objclsSkillsMasterDAL.GetAllSkills(); ;
            rptSkills.DataSource = objIN_TB_SKILL_MST;
            rptSkills.DataBind();
        }
        catch (Exception)
        {

            throw;
        }
    }



    protected void btnClearSearch_Click(object sender, EventArgs e)
    {
        try
        {
            txtKeySkills.Text = "";
        }
        catch (Exception)
        {

            throw;
        }
    }
    protected void grdSeachBySkills_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {

        }
        catch (Exception)
        {

            throw;
        }
    }
    //protected void grdSeachBySkills_RowCommand(object sender, GridViewCommandEventArgs e)
    //{
    //    if (e.CommandName == "ApplyJob")
    //    {
    //        if (Session["UserId"] != null)
    //        {
    //            int JobPostId = Convert.ToInt32(e.CommandArgument.ToString());
    //            if (JobPostId != 0)
    //            {
    //                LinkButton objLinkbutton = (LinkButton)e.CommandSource;
    //                string Id = objLinkbutton.ClientID;
    //                string no = Id.Replace("ctl00_cphMainBody_grdSeachBySkills_ctl", "");
    //                no = no.Replace("_lnkApplyNow", "");
    //                int RowNo = Convert.ToInt32(no);
    //                RowNo = RowNo - 2;
    //                HiddenField hfJobPostId = (HiddenField)grdSeachBySkills.Rows[RowNo].FindControl("hfJobPostId");
    //                if (hfJobPostId.Value != "")
    //                {
    //                    int Job_PostId = Convert.ToInt32(hfJobPostId.Value.ToString());
    //                    clsSearchJob objclsSearchJob = new clsSearchJob();
    //                    clsSearchResult objclsSearchResult = objclsSearchJob.GetJobByJobPostId(Job_PostId);
    //                    string postid = Convert.ToString(Job_PostId);
    //                    postid = clsEncryptionDecryption.EncryptQueryString(postid);
    //                    string companyname = Convert.ToString(objclsSearchResult.COMPANY_NAME);
    //                    companyname = clsEncryptionDecryption.EncryptQueryString(companyname);
    //                    string companydetails = Convert.ToString(objclsSearchResult.COMPANY_DESCRIPTION);
    //                    companydetails = clsEncryptionDecryption.EncryptQueryString(companydetails);
    //                    string jobtitle = Convert.ToString(objclsSearchResult.JOB_TITLE);
    //                    jobtitle = clsEncryptionDecryption.EncryptQueryString(jobtitle);
    //                    string jobdesc = Convert.ToString(objclsSearchResult.JOB_DESCRIPTION);
    //                    jobdesc = clsEncryptionDecryption.EncryptQueryString(jobdesc);
    //                    string skillsreq = Convert.ToString(objclsSearchResult.SKILLS_REQUIRED);
    //                    skillsreq = clsEncryptionDecryption.EncryptQueryString(skillsreq);
    //                    string joblocid = Convert.ToString(objclsSearchResult.JOB_LOCATION);
    //                    joblocid = clsEncryptionDecryption.EncryptQueryString(joblocid);
    //                    string expreq = Convert.ToString(objclsSearchResult.EXPERIENCE_REQUIRED);
    //                    expreq = clsEncryptionDecryption.EncryptQueryString(expreq);
    //                    string qualificationreq = Convert.ToString(objclsSearchResult.QUALIFICATION_REQUIRED);
    //                    qualificationreq = clsEncryptionDecryption.EncryptQueryString(qualificationreq);
    //                    string salaryoffered = Convert.ToString(objclsSearchResult.SALARY_OFFERED);
    //                    salaryoffered = clsEncryptionDecryption.EncryptQueryString(salaryoffered);
    //                    string functionalareaid = Convert.ToString(objclsSearchResult.FUNCTIONAL_AREA);
    //                    functionalareaid = clsEncryptionDecryption.EncryptQueryString(functionalareaid);
    //                    string jobpostedon = Convert.ToString(objclsSearchResult.JOB_POSTED_ON);
    //                    jobpostedon = clsEncryptionDecryption.EncryptQueryString(jobpostedon);

    //                    if (Request.QueryString["roleid"] != null)
    //                        Response.Redirect("Job_Details.aspx?roleid=" + Request.QueryString["roleid"].ToString() + "&postid=" + postid + "&companyname=" + companyname + "&companydetails=" + companydetails + "&jobtitle=" + jobtitle + "&jobdesc=" + jobdesc + "&skillsreq=" + skillsreq + "&joblocid=" + joblocid + "&expreq=" + expreq + "&qualificationreq=" + qualificationreq + "&salaryoffered=" + salaryoffered + "&functionalareaid=" + functionalareaid + "&jobpostedon=" + jobpostedon);
    //                    else
    //                    {
    //                        lblErrMsg.Text = "";
    //                        Response.Redirect("JobSeekerLogin.aspx");
    //                    }

    //                }
    //                //lblErrMsg.Text = "You have successfully applied job your application id is :" + JobAppliedId.ToString();
    //                //Fillgrd();
    //            }
    //        }
    //        else
    //        {
    //            lblErrMsg.Text = "";
    //            Response.Redirect("JobSeekerLogin.aspx");
    //        }
    //    }
    //}
    protected void rptSkills_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (Convert.ToString(e.CommandName) == "SkillsSearch")
        {
            string skill = Convert.ToString(e.CommandArgument);

            if (skill != "")
            {
                mode = clsEncryptionDecryption.EncryptQueryString(mode);
                Response.Redirect("JobSearchResult.aspx?mode=" + mode + "&skillset=" + clsEncryptionDecryption.EncryptQueryString(skill.Trim().ToLower()) + "&roleid=" + Convert.ToString(Request.QueryString["roleid"]));
            }

        }
    }
}
